#pragma once

#include <vector>

#include "kconfig.h"
#include "ktoken.h"

#define OBJECT_COUNT 5

#define METHOD_COUNT 19

#define FUNC_COUNT 19

class Lexer
{
private:
	char* source;
	k_uint index;
	k_uint line;
	std::vector<Token> tokenList;
	Token tok;
	Token oldtok;
	k_string tmpstr;

	k_uint strPoolSize;

public:
	Lexer() : source(0), index(0), tokenList(), tok(TOK_NULL), oldtok(TOK_NULL), strPoolSize(0) {}

	void Scan(const char* src);

	k_uint GetStringPoolSize() const;

	std::vector<Token> GetTokenList() const;

	void CleanUp();

private:
	void ScanSymbol();

	void ScanNumber();

	void ScanString();

	void IgnoreWhite();

	int GetObjectIndex();

	int GetMethodIndex();

	int GetFuncIndex();
};
